package com.lagou.sqlSession;

import com.lagou.config.XMLConfigBuilder;
import com.lagou.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * @author DingYiYuan
 * @description
 * @time 2021/3/9 16:23
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream in) throws DocumentException, PropertyVetoException {

        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        //调用XMLConfigBuilder方法解析配置文件生产Configuration配置信息
        Configuration configuration = xmlConfigBuilder.parseConfig(in);


        //根据Configuration配置信息创建session工厂
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;
    }


}
